#include <map>
#include <string>
#include <FTGL\ftgl.h>

using namespace std;

//typedef map<string, FTFont*> FontList;
//typedef FontList::const_iterator FontIter;

class FTGLFontManager
{
    public:
        // NOTE
        // This is shown here for brevity. The implementation should be in the source
        // file otherwise your compiler may inline the function resulting in
        // multiple instances of FTGLFontManager
        static FTGLFontManager& Instance()
        {
            static FTGLFontManager tm;
            return tm;
        }

        ~FTGLFontManager()
        {
            //FontIter font;
            //for(font = fonts.begin(); font != fonts.end(); font++)
            //{
            //    delete (*font).second;
            //}

            //fonts.clear();
        }


        FTGLPixmapFont* GetFont(const char *filename, int size)
        {
            char buf[256];
            sprintf(buf, "%s%i", filename, size);
            string fontKey = string(buf);

            //FontIter result = fonts.find(fontKey);
            //if(result != fonts.end())
            //{
            //    printf("Found font %s in list", filename);
            //    return result->second;
            //}

			FTGLPixmapFont font(filename) ;

           	if(font.Error())
				return NULL;

			font.FaceSize(size);

            return &font;
        }


    private:
        // Hide these 'cause this is a singleton.
        FTGLFontManager(){}
        FTGLFontManager(const FTGLFontManager&){};
        FTGLFontManager& operator = (const FTGLFontManager&){ return *this; };

        // container for fonts
        FontList fonts;
};